import React from 'react';
import {Checkbox} from 'antd';
import {WeaFormItem, WeaColorPicker} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

// 提醒方式
class ERemindMode extends React.Component {
    state = {
        eRemindMode: this.props.value
    };

    render() {
        const {eRemindMode} = this.state;

        let eRemindModeList = [];
        for (let key in eRemindMode) {
            if (eRemindMode.hasOwnProperty(key)) {
                eRemindModeList.push(
                    <li style={{display: 'inline-block'}}>
                        <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@kp1vgb@${key}`}
                            checked={eRemindMode[key].checked}
                            onChange={
                                e => this.setState({
                                    eRemindMode: {
                                        ...eRemindMode, [key]: {...eRemindMode[key], checked: e.target.checked}
                                    }
                                })
                            }
                        >
                            {eRemindMode[key].label}
                        </Checkbox>
                        {
                            key == 'color' ?
                                <div style={{display: 'inline-block', width: '100px'}}>
                                    <WeaColorPicker ecId={`${this && this.props && this.props.ecId || ''}_WeaColorPicker@ilkyij@${key}`}
                                        value={eRemindMode[key].color}
                                        onChange={
                                            (value) => this.setState({
                                                eRemindMode: {
                                                    ...eRemindMode, 'color': {...eRemindMode['color'], color: value}
                                                }
                                            })
                                        }
                                    />
                                </div> : ''
                        }
                    </li>
                );
            }
        }

        return (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@n5bgqa`} label={getLabel(18713, '提醒方式')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <ul ref="eRemindMode">{eRemindModeList}</ul>
            </WeaFormItem>
        );
    }

    getSaveValues() {
        return this.state.eRemindMode;
    }
}

export default ERemindMode;
